#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "graphgui.h"

#include <QGraphicsScene>
#include <QVBoxLayout>
#include <QSignalTransition>

#include <QtDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	scene = 0;
    ui->setupUi(this);
	ui->graphicsView->setInteractive(true);
	ui->graphicsView->viewport()->setMouseTracking(true);
//	ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
//	connect(ui->pushButton, SIGNAL(clicked()), SLOT(drawGraph()));

	gcWidget = new GraphControlWidget(this);
	gcWidget->setAllowedAreas(Qt::AllDockWidgetAreas);
	gcWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
	addDockWidget(Qt::RightDockWidgetArea, gcWidget);

//	gcWidget->show();

	connect(gcWidget, SIGNAL(newGraph(QGraphicsScene*)), this, SLOT(drawGraph(QGraphicsScene*)));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::drawGraph(QGraphicsScene *s)
{
	if (!s)
		return;
	scene = s;
	ui->graphicsView->setScene(s);
	QGraphicsItem *item = scene->mouseGrabberItem();
	if (item)
		qDebug("mouse grabber item");
}
